package com.qianfeng.smartdevices.controller;


import com.qianfeng.smartdevices.annotations.AopLogAnnotation;
import com.qianfeng.smartdevices.dto.R;
import com.qianfeng.smartdevices.pojo.RoleMenu;
import com.qianfeng.smartdevices.service.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rolemenus")
public class RoleMenuController {
    private RoleMenuService roleMenuService;
    @Autowired
    public void setRoleMenuService(RoleMenuService roleMenuService) {
        this.roleMenuService = roleMenuService;
    }

    @PostMapping("/rolemenus")
    @AopLogAnnotation("角色菜单表添加")
    public R addRoleMenu(@RequestBody RoleMenu roleMenu){
        roleMenuService.addRoleMenu(roleMenu);
        return R.setOK();
    }
    @GetMapping("/rolemenus")
    @AopLogAnnotation("角色菜单表查询")
    public R findALLRoleMenu(){
        List<RoleMenu> allRoleMenu = roleMenuService.findALLRoleMenu();
        return R.setOK(allRoleMenu);
    }
    @PutMapping("/rolemenus")
    @AopLogAnnotation("角色菜单表更新")
    public R updateRoleMenu(@RequestParam Long roleId,@RequestParam Long menuId,@RequestParam Long id){
        roleMenuService.updateRoleMenu(roleId,menuId,id);
        return R.setOK();
    }
}
